const path = require('path');
const { VueLoaderPlugin } = require('vue-loader');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');

module.exports = {
  target: 'web',
  entry: './src/main.js',
  module: {
    rules: [
      { test: /\.js$/, use: 'babel-loader' },
      { test: /\.vue$/, loader: 'vue-loader' },
      {
        test: /\.css$/,
        use: ['vue-style-loader', 'css-loader'],
      },
      { test: /\.less$/, use: ['style-loader', 'css-loader', 'less-loader'] },
      {
        test: /\.(png|jpg|gif)$/,
        type: 'asset',
      },
    ],
  },

  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].bundle.js',
    clean: true,
  },
  plugins: [
    new VueLoaderPlugin(),
    new ESLintPlugin({ extensions: ['js', 'vue'], failOnWarning: true }),
    new HtmlWebpackPlugin({
      title: 'My App',
      url: 'public/',
      template: 'public/index.html',
    }),
  ],
};
